/*
 * @Descripttion: 创建一个组件映射表，将文件路径中的组件名称与其对应的动态导入函数关联起来
 * @version:
 * @Author: lhl
 * @Date: 2024-10-24 16:19:15
 * @LastEditors: lhl
 * @LastEditTime: 2024-10-24 16:20:43
 */
import React from 'react';

const modules = import.meta.glob('../views/**/*.tsx');

export const componentMap: Record<string, () => Promise<React.ComponentType>> = Object.keys(modules).reduce(
  (acc, path) => {
    const componentName = path.split('/').pop()?.replace('.tsx', '') || '';
    acc[componentName] = modules[path] as () => Promise<React.ComponentType>;
    return acc;
  },
  {} as Record<string, () => Promise<React.ComponentType>>
);
